<?php
	$name 			= $this->formText ( 'name', $this->Item['name'], array ('class' => 'txtlong') ) . '<div class="view_error" id="view_name"></div>';
	$slbCategory	= $this->cmsSelect('id_cat',$this->Item['id_cat'],$this->slbCategory,array('size'=>0,'style'=>'min-width:200px;','class' => 'select', 'onchange' => 'loadSubcat(this)')) . '<div class="view_error" id="view_id_cat"></div>';
	if(!empty($this->Item['id_nhucau'])){
		$slbNhucau		= $this->formselect('id_nhucau',$this->Item['id_nhucau'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select'), $this->slbNhucau) . '<div class="view_error" id="view_id_nhucau"></div>';
	}else{
		$slbNhucau		= $this->formselect('id_nhucau',$this->Item['id_nhucau'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select', 'disabled' => 'disabled'), $this->slbNhucau) . '<div class="view_error" id="view_id_nhucau"></div>';
	}
	
	if(!empty($this->Item['id_nhucau'])){
		$slbChungloai	= $this->formselect('id_chungloai',$this->Item['id_chungloai'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select'), $this->slbChungloai) . '<div class="view_error" id="view_id_chungloai"></div>';
	}else{
		$slbChungloai	= $this->formselect('id_chungloai',$this->Item['id_chungloai'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select', 'disabled' => 'disabled'), $this->slbChungloai) . '<div class="view_error" id="view_id_chungloai"></div>';
	}
	
	$slbCity	= $this->formselect('id_city',$this->Item['id_city'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select', 'onchange' => 'loadDistrict(this)'),$this->slbCity) . '<div class="view_error" id="view_id_city"></div>';
	if(!empty($this->Item['id_district'])){
		$slbDistrict	= $this->formselect('id_district',$this->Item['id_district'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select'), $this->slbDistrict) . '<div class="view_error" id="view_id_district"></div>';
	}else{
		$slbDistrict	= $this->formselect('id_district',$this->Item['id_district'],array('size'=>0,'style'=>'min-width:200px;','class' => 'select', 'disabled' => 'disabled'), $this->slbDistrict) . '<div class="view_error" id="view_id_district"></div>';
	}
	
	// Thong tin lien he
	$info 				= new Zendvn_System_Info();
	$user_info 			= $info->getMemberInfo();
	echo '<pre>';
	print_r($user_info);
	echo '</pre>';
	$lienhe_hoten = $user_info['member_hoten'];
	if(!empty($this->Item['lienhe_hoten'])){
		$lienhe_hoten = $this->Item['lienhe_hoten'];
	}
	$lienhe_hoten 		= $this->formText ( 'lienhe_hoten', $lienhe_hoten, array ('class' => 'txtmedium') ) . '<div class="view_error" id="view_lienhe_hoten"></div>';
	
	//-------------------- SESSAGES ERROR ------------------
	if(count($this->messageError)>0){
		foreach ($this->messageError AS $key => $val){
			echo '<div class="listError" id="'.$key.'" rel="' . $val . '"></div>';
		}
	}
?>
<script type="text/javascript">
    $(function() {
    	$.datepicker.setDefaults($.datepicker.regional['vi']);
        $( "#datepicker" ).datepicker({
            changeMonth: true,
            changeYear: true,
            minDate: 0,
            dateFormat: 'dd/mm/yy'
        });
    });
    function loadSubcat(e){
    	id_cat = $(e).val();
    	if(id_cat > 0){
	    	$('#dangtai').show();
	    	$('#load_nhucau').load('<?php echo $this->baseUrl('default/user-item/nhucau/id_cat/')?>' + id_cat, 
	    	    function(){
	    	    	$('#dangtai').hide();
	    	    }
		    );
	    	$('#dangtai').show();
	    	$('#load_chungloai').load('<?php echo $this->baseUrl('default/user-item/chungloai/id_cat/')?>' + id_cat, 
		        function(){
		        	$('#dangtai').hide();
		        }
			);
    	}else{
    		$('#load_nhucau').html('<select disabled="disabled" class="select" style="min-width:200px;" size="0" id="id_nhucau" name="id_nhucau"><option label="=== Chọn nhu cầu =======" value="0">=== Chọn nhu cầu =======</option></select>')
    		$('#load_chungloai').html('<select disabled="disabled" class="select" style="min-width:200px;" size="0" id="id_chungloai" name="id_chungloai"><option label="=== Chọn chủng loại =======" value="0">=== Chọn chủng loại =======</option></select>')
    	}
    }

    function loadDistrict(e){
    	id_city = $(e).val();
    	if(id_city != 0){
	    	$('#dangtai').show();
	    	$('#load_district').load('<?php echo $this->baseUrl('default/user-item/district/id_city/')?>' + id_city, 
	    	    function(){
	    	    	$('#dangtai').hide();
	    	    }
		    );
    	}else{
    		$('#load_district').html('<select disabled="disabled" class="select" style="min-width:200px;" size="0" id="id_district" name="id_district"><option label="=== Chọn quận huyện =====" value="0">=== Chọn quận huyện =====</option></select>')
    	}
    }
</script>
<div class="module_user">
	<?php echo $this->render( $this->arrParam['controller'] . '/toolbar/left.php');?>
	<div class="center_user">
		<div class="userApp">
			<div class="block_title"><?php echo $this->Title;?></div>
			<div class="block_content">
				<form name="userForm" method="post" action="" enctype="multipart/form-data">
					<div class="inputForm">
						<table class="tblForm">
							<tr>
								<td class="label">Tiêu đề <span class="red">(*)</span></td>
								<td><?php echo $name;?></td>
							</tr>
							<tr>
								<td colspan="2">
									<div class="col_left">
										<table class="tblForm">
											<tr>
												<td class="label">Chuyên mục <span class="red">(*)</span></td>
												<td><?php echo $slbCategory;?></td>
											</tr>
											<tr>
												<td class="label">Nhu cầu</td>
												<td>
													<div id="load_nhucau">
														<?php echo $slbNhucau;?>
													</div>
												</td>
											</tr>
											<tr>
												<td class="label">Chủng loại</td>
												<td>
													<div id="load_chungloai">
														<?php echo $slbChungloai;?>
													</div>
												</td>
											</tr>
											<tr>
												<td class="label">Nơi rao</td>
												<td>
													<?php echo $slbCity;?>
												</td>
											</tr>
											<tr>
												<td class="label">Quận huyện</td>
												<td>
													<div id="load_district">
														<?php echo $slbDistrict;?>
													</div>
												</td>
											</tr>
										</table>
									</div>
									<div class="col_right">
										<div class="lienhe">
											<div class="title">Thông tin liên hệ</div>
											<table class="tblForm">
												<tr>
													<td class="label">Họ tên</td>
													<td>
														<?php echo $lienhe_hoten;?>
													</td>
												</tr>
											</table>
										</div>
									</div>
								</td>
							</tr>
						</table>
						<div class="block_botton">
							<a onclick="OnSubmitForm('/raovat/default/user-item/add')" href="#" class="btnDangtin">Đăng tin</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<div class="clr"></div>
</div>